using System;
using System.Collections.Generic;
using System.Text;
using Objects;

namespace DAL
{
    public class DALMenhGia
    {
        public List<MenhGia> GetAllItem()
        {
            List<MenhGia> ListMenhGia = new List<MenhGia>();

            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@Status" };
            string[] vname = new string[] { Common.Myconst.HOATDONG.ToString()};
            System.Data.DataSet ds = acc.CommandSelect("MenhGia_GetAllItem", sname, vname);

            MenhGia Item = new MenhGia();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                System.Data.DataRow dr = ds.Tables[0].Rows[i];
                ListMenhGia.Add((Item.Populate(dr)));
            }
            return ListMenhGia;
        }


        public MenhGia GetById(int Id)
        {
            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@Status", "@Id" };
            string[] vname = new string[] { Common.Myconst.HOATDONG.ToString(),Id.ToString() };
            System.Data.DataSet ds = acc.CommandSelect("MenhGia_GetById", sname, vname);

            MenhGia Item = new MenhGia();
          
                System.Data.DataRow dr = ds.Tables[0].Rows[0];
               return Item.Populate(dr);
        }


        public int Insert_MenhGia(String MenhGia, int SapXep)
        {
            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@MenhGia","@Status", "@SapXep" };
            string[] vname = new string[] { MenhGia.ToString(), Common.Myconst.HOATDONG.ToString(), SapXep.ToString() };
            return acc.InsertUpdateDetete("MenhGia_Insert", sname, vname);

        }

        public int Update_MenhGia(int id, String MenhGia,int SapXep)
        {
            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@Id", "@MenhGia","@Status", "@SapXep" };
            string[] vname = new string[] { id.ToString(), MenhGia.ToString(), Common.Myconst.HOATDONG.ToString(), SapXep.ToString() };
            return acc.InsertUpdateDetete("MenhGia_Update", sname, vname);

        }

        public int Delete_MenhGia(int id)
        {
            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@id" };
            string[] vname = new string[] { id.ToString() };
            return acc.InsertUpdateDetete("MenhGia_Delete", sname, vname);

        }
    }
}
